//
//  ExamineProprietorPositionHouseView.swift
//  SmartHousekeeper
//
//  Created by 张磊 on 2020/2/21.
//  Copyright © 2020 LS. All rights reserved.
//

import UIKit
//房屋信息验证
class ExamineProprietorPositionHouseView: UIView {
    
   typealias ExamineProprietorPositionHouseView = ()->()
      public var nextHouseBlock : ExamineProprietorPositionHouseView? = nil
      
      
      lazy var nextBtn : UIButton = {
          let value = UIButton(textColor: .white, textFont: UIFont.boldSystemFont(ofSize: Adapter(17)))
          value.setTitle("下一步", for: .normal)
          value.backgroundColor = RGBColor(r: 62, g: 134, b: 230, a: 1)
          value.layer.cornerRadius = Adapter(5)
          value.layer.masksToBounds = true
          return value
      }()
     
    lazy var houseView : UIView = {
        let value = UIView()
        value.layer.borderWidth = 1
        value.layer.borderColor = RGBColor(r: 140, g: 140, b: 140, a: 1).cgColor
        value.layer.cornerRadius = Adapter(8)
        return value
    }()
    
    lazy var houseBtn : UIButton = {
           let value = UIButton()
           value.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
           value.setTitle("小区名称", for: .normal)
           value.setTitleColor(RGBColor(r: 103, g: 103, b: 103, a: 1), for: .normal)
           return value
       }()
    
    lazy var scanBtn : UIButton = {
             let value = UIButton()
        value.setImage(UIImage(named: "icon_scan"), for: .normal)
             return value
         }()
        
      
      lazy var homeBtn : UIButton = {
          let value = UIButton()
          value.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
          value.setTitle("所在房屋", for: .normal)
          value.setTitleColor(RGBColor(r: 103, g: 103, b: 103, a: 1), for: .normal)
          value.layer.cornerRadius = Adapter(8)
          value.layer.masksToBounds = true
          value.layer.borderWidth = 1
          value.layer.borderColor = RGBColor(r: 140, g: 140, b: 140, a: 1).cgColor
          return value
      }()
      
      lazy var houseNumText : UITextField = {
          let value = UITextField()
          value.placeholder = "请输入房产证编号"
          value.font = UIFont.boldSystemFont(ofSize: 15)
          value.textColor = RGBColor(r: 103, g: 103, b: 103, a: 1)
          value.textAlignment = .center
          value.delegate = self as? UITextFieldDelegate
          value.layer.cornerRadius = Adapter(8)
          value.layer.masksToBounds = true
          value.layer.borderWidth = 1
          value.layer.borderColor = RGBColor(r: 140, g: 140, b: 140, a: 1).cgColor
          value.keyboardType = .numberPad
          return value
      }()
      
    
   
       required init?(coder: NSCoder) {
           super .init(coder: coder)
       }
       override init(frame: CGRect) {
           super .init(frame: frame)
           setUI()
       }
       private func setUI(){
           
           //"所在小区:"
           let houseL = UILabel(textColor: RGBColor(r: 116, g: 116, b: 116, a: 1), textFont: UIFont.systemFont(ofSize: 13))
           houseL.text = "所在小区:"
           self.addSubview(houseL)
           houseL.snp.makeConstraints { (make) in
               make.left.equalToSuperview().offset(Adapter(22))
               make.top.equalToSuperview().offset(Adapter(22))
               make.height.equalTo(Adapter(15))
           }
           self.addSubview(houseView)
           houseView.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(Adapter(22))
            make.right.equalToSuperview().offset(Adapter(-22))
            make.top.equalTo(houseL.snp.bottom).offset(Adapter(10))
            make.height.equalTo(Adapter(45))
         }
    
        let line = UIView()
        line.backgroundColor = RGBColor(r: 116, g: 116, b: 116, a: 1)
        self.addSubview(line)
        line.snp.makeConstraints { (make) in
            make.left.equalTo(houseView.snp.right).offset(-45)
            make.top.bottom.equalTo(houseView)
            make.width.equalTo(1)
        }
        
        houseView.addSubview(houseBtn)
           houseBtn.snp.makeConstraints { (make) in
            make.left.top.bottom.equalToSuperview()
            make.right.equalTo(line)
           }
        houseView.addSubview(scanBtn)
        scanBtn.snp.makeConstraints { (make) in
            make.right.top.bottom.equalToSuperview()
            make.left.equalTo(line)
        }
           
           //所在房屋
           let homeL = UILabel(textColor: RGBColor(r: 116, g: 116, b: 116, a: 1), textFont: UIFont.systemFont(ofSize: 13))
           homeL.text = "所在房屋:"
           self.addSubview(homeL)
           homeL.snp.makeConstraints { (make) in
               make.left.equalToSuperview().offset(Adapter(22))
               make.top.equalTo(houseView.snp.bottom).offset(Adapter(25))
               make.height.equalTo(Adapter(15))
           }
           self.addSubview(homeBtn)
           homeBtn.snp.makeConstraints { (make) in
               make.left.equalToSuperview().offset(Adapter(22))
               make.right.equalToSuperview().offset(Adapter(-22))
               make.top.equalTo(homeL.snp.bottom).offset(Adapter(10))
               make.height.equalTo(Adapter(45))
           }
     
           
           //房产证编号
           let houseNumL = UILabel(textColor: RGBColor(r: 116, g: 116, b: 116, a: 1), textFont: UIFont.systemFont(ofSize: 13))
           houseNumL.text = "房产证编号:"
           self.addSubview(houseNumL)
           houseNumL.snp.makeConstraints { (make) in
               make.left.equalToSuperview().offset(Adapter(22))
               make.top.equalTo(homeBtn.snp.bottom).offset(Adapter(25))
               make.height.equalTo(Adapter(15))
           }
           
           self.addSubview(houseNumText)
           houseNumText.snp.makeConstraints { (make) in
               make.left.equalToSuperview().offset(Adapter(22))
               make.right.equalToSuperview().offset(Adapter(-22))
               make.top.equalTo(houseNumL.snp.bottom).offset(Adapter(10))
               make.height.equalTo(Adapter(45))
           }
           
           
           self.addSubview(nextBtn)
           nextBtn.snp.makeConstraints { (make) in
               make.bottom.equalToSuperview().offset(Adapter(-50))
               make.height.equalTo(Adapter(45))
               make.left.equalToSuperview().offset(Adapter(50))
               make.right.equalToSuperview().offset(Adapter(-50))
           }
           
           nextBtn.sce.add(.touchUpInside) { (btn) in
               //            if self.nameText.text!.isEmpty {
               //               print("请输入姓名")
               //            } else if self.idCardText.text!.isEmpty {
               //                print("请输入身份证")
               //            } else if !isIDCard(idCard: self.idCardText.text!) {
               //                print("身份证格式不正确")
               //            } else if self.iphoneText.text!.isEmpty {
               //                print("请输入手机号")
               //            } else if !isChinaPhone(str: self.iphoneText.text!) {
               //                print("手机号格式不正确")
               //            } else {
               if self.nextHouseBlock != nil {
                   self.nextHouseBlock!()
               }
               //            }
           }
           
       }
}
